package cn.com.zh.app.collector.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;

public class DateUtil {

	public static String convertDateToString(Date date,String pattern) {
		
		if(date==null) {
			return null;
		}
		if(StringUtils.isBlank(pattern)) {
			pattern="yyyy-MM-dd HH:mm:SS";
		}
		SimpleDateFormat sdf=new SimpleDateFormat(pattern);
		return sdf.format(date);
	}
	
	
	
	public static void main(String[] args) {
		String s1=convertDateToString(new Date(), null);
		String s2=convertDateToString(new Date(), "yyyy-MM-dd HH:mm:SS");
		
		System.out.println(s1);
		System.out.println(s2);

	}
}
